﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TheVoiceOfSnake.Enums;

namespace TheVoiceOfSnake.Models
{
    public static class Commands
    {
        public static Dictionary<Direction, double> CommandsDct;

        static Commands() 
        {
            CommandsDct = new Dictionary<Direction, double>();
            CommandsDct.Add(Direction.Left, 0.01);
            CommandsDct.Add(Direction.Right, 0.35);
            CommandsDct.Add(Direction.Up, 0.7);
            CommandsDct.Add(Direction.Down, 0.99);
            //CommandsDct.Add(Direction.Left, 0.2);
            //CommandsDct.Add(Direction.Right, 0.4);
            //CommandsDct.Add(Direction.Up, 0.6);
            //CommandsDct.Add(Direction.Down, 0.8);
            CommandsDct.Add(Direction.None, -1);
        }

        public static string TransformCommandToString(Direction direction) 
        {
            switch (direction) 
            {
                case Direction.Down:
                    return "Dół";

                case Direction.Up:
                    return "Góra";

                case Direction.Left:
                    return "Lewo";

                case Direction.Right:
                    return "Prawo";
                    
                default:
                    return "Brak";
            }
        }

        public static Direction TransformCommandToDirection(string direction)
        {
            switch (direction.ToLower())
            {
                case "dół":
                    return Direction.Down;

                case "góra":
                    return Direction.Up;

                case "lewo":
                    return Direction.Left;

                case "prawo":
                    return Direction.Right;

                default:
                    return Direction.None;
            }
        }

        public static Direction CheckResult(double value)
        {
            foreach (var item in Commands.CommandsDct)
            {
                if (item.Value == value)
                {
                    return item.Key;
                }
            }
            return Direction.None;
        }
    }
}
